package edu.wpi.cs509.ui.intfc;

import java.util.List;

import edu.wpi.cs509.clientlogic.UserSession;
import edu.wpi.cs509.representation.GameListItem;

/**
 * This interface defines the methods that the Client Logic will
 * invoke to notify the UI of asynchronous notification events.
 * 
 * @author afoltan
 *
 */
public interface ClientLogicNotify {
	
	public enum FailureReason {
		InvalidCredentials,
		GameNotFound,
		GameNotJoinable,
		ServerLimitReached,
	};
	
	/**
	 * Notifies the User Interface of the result of a login attempt.
	 * @param session
	 */
	void notifyLoginSuccess( UserSession session );
	
	// logout - no notification required

	/**
	 * Notifies the User Interface of the leader board statistics
	 * @param statsList - the ordered list of players
	 * @param rank - the starting rank of the first player
	 */
	void notifyLeaderBoard( List<PlayerStatsInterface> statsList, int rank, int totalPlayers );
	
	/**
	 * Notifies the User Interface of the individual players statistics
	 * @param myStats - the player statistics
	 */
	void notifyPlayerStats( PlayerStatsInterface myStats );
	
	/**
	 * Notifies the User Interface of the list of games on the server
	 * @param games - the list of all games
	 */
	void notifyGames( List<GameListItem> games );
	
	/**
	 * Indicates a player has successfully joined a game; either a new game or
	 * a game that was joined
	 * 
	 * @param game - the game being joined
	 */
	void notifyGameJoined( GameInterface game );

	/**
	 * Indicates a player begun observing a game
	 * 
	 * @param game - the game being joined
	 */
	void notifyGameObserved( GameInterface game );

	/**
	 * Notifies the UserInterface of the Stratego Rules
	 * @param rules
	 */
	void notifyRulesPage( RulesInterface rules );

	/**
	 * Asynchronous notification for failures
	 */
	void notifyFailure( FailureReason reason );
	
	//
	//  UNSOLICITED NOTIFICATIONS
	//
	
	/**
	 * Indicates the connection to the server has been lost
	 */
	void ServerConnectionLost();
	
}
